package com.woniu.account.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.account.model.TResource;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 吴彦祖
 * @since 2024年04月02日
 */
@Mapper
public interface TResourceMapper extends BaseMapper<TResource> {

    @Select("SELECT r.* FROM t_admin_role ar\n" +
            "                            LEFT JOIN t_permission p ON ar.role_id=p.role_id\n" +
            "                            LEFT JOIN t_resource r ON p.resource_id=r.resource_id\n" +
            "        WHERE ar.admin_id=#{userId} AND r.level&lt;3")
    List<TResource> selectMenu(Integer userId);

    @Select(" SELECT distinct r.* FROM t_admin_role ar\n" +
            "                                     LEFT JOIN t_permission p ON ar.role_id=p.role_id\n" +
            "                                     LEFT JOIN t_resource r ON p.resource_id=r.resource_id\n" +
            "        WHERE ar.admin_id=#{userId} AND r.`LEVEL`=3")
    List<TResource> findButton(Integer userId);
}
